const express = require('express')

const app = express()

// 处理跨域
app.use(require('cors')())
// 处理post请求数据
app.use(express.json())
// 处理靜态文件
app.use('/uploads', express.static(__dirname + '/uploads'))

// 连接数据库
require('./plugins/db')(app)
require('./routes/admin/admin')(app)
require('./routes/admin/upload')(app)

app.listen(5000, err => {
  if (!err) return console.log('服务器启动成功')
  console.log(err)
})